package com.un.ebs.sale.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.un.ebs.sale.domain.FinanceBySaleExt;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * (FinanceBySaleExt)表数据库访问层
 *
 * @author liubo
 * @since 2020-12-15 13:57:06
 */
public interface FinanceBySaleExtMapper extends BaseMapper<FinanceBySaleExt> {

    @Select("SELECT tenant_id,account_year,account_month,note_type_name,note_type,SUM(cost_money) AS cost_money,SUM(production_cost_money) AS production_cost_money,SUM(purchase_cost_money) AS purchase_cost_money FROM [v_finance_by_sale_ext] WHERE type IN ( 1, 2 ) and account_year=#{year} and account_month=#{month} and tenant_id=#{tenantId} GROUP BY tenant_id,account_year,account_month,note_type_name,note_type")
    FinanceBySaleExt selectFinanceBySale(@Param("year") int year, @Param("month") int month, @Param("tenantId") String tenantId);

    @Select("SELECT tenant_id,account_year,account_month,note_type_name,note_type,SUM(cost_money) AS cost_money,SUM(production_cost_money) AS production_cost_money,SUM(purchase_cost_money) AS purchase_cost_money FROM [v_finance_by_sale_ext] WHERE type=4 and account_year=#{year} and account_month=#{month} and tenant_id=#{tenantId} GROUP BY tenant_id,account_year,account_month,note_type_name,note_type")
    FinanceBySaleExt selectFinanceByService(@Param("year") int year, @Param("month") int month,@Param("tenantId") String tenantId);
}